package com.tangfuzhong.test;

import com.tangfuzhong.util.MyApplicationAware;
import org.junit.Test;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.core.env.ConfigurableEnvironment;

import com.tangfuzhong.bean.Person;
import com.tangfuzhong.config.Config04_Value_PropertySource;

/**
 * @Value 具体定义看Person.java
 * @PropertySource  具体使用看Config05_Value_PropertySource.java
 */
public class IOCTest_04_Value_PropertySource {

	@Test
	public void test01(){
		AnnotationConfigApplicationContext applicationContext
				= new AnnotationConfigApplicationContext(Config04_Value_PropertySource.class);

		MyApplicationAware.printBeans(applicationContext);

		System.out.println("=============");
		
		Person person = (Person) applicationContext.getBean("person");
		System.out.println(person);
		
		
		ConfigurableEnvironment environment = applicationContext.getEnvironment();
		String property = environment.getProperty("person.nickName");
		System.out.println(property);
		applicationContext.close();
	}


}
